const { src, dest } = require("gulp");
const babel = require("gulp-babel");
const terser = require("gulp-terser");

const jsTask = () => {
  //读取文件and写入文件
  return src("./src/**/*.js")
    .pipe(babel({ presets: ["@babel/preset-env"] })) //转化es6==>es5
    .pipe(terser({ mangle: { toplevel: true } })) //压缩丑化
    .pipe(dest("./dist"));
};

module.exports = {
  jsTask,
};
